<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>昵称：</label>
                                <input type="text" name="username"/>
                            </li>
                            <li>
                                <label>手机号：</label>
                                <input type="text" name="phone"/>
                            </li>
<!--                            <li>-->
<!--                                <label>密码：</label>-->
<!--                                <input type="text" name="password"/>-->
<!--                            </li>-->
                            <li>
                                <label>性别：</label>
                                <select name="sex" th:with="type=${@dict.getType('sys_user_sex')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
<!--                            <li>-->
<!--                                <label>头像：</label>-->
<!--                                <input type="text" name="photo"/>-->
<!--                            </li>-->
                            <li>
                                <label>用户类型：</label>
                                <select name="type" th:with="type=${@dict.getType('used_merchant')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>地址：</label>
                                <input type="text" name="address"/>
                            </li>
<!--                            <li>-->
<!--                                <label>上级用户id：</label>-->
<!--                                <input type="text" name="fid"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>信誉积分：</label>-->
<!--                                <input type="text" name="creditScore"/>-->
<!--                            </li>-->
                            <li>
                                <label>邀请码：</label>
                                <input type="text" name="inviteCode"/>
                            </li>
<!--                            <li>-->
<!--                                <label>简介：</label>-->
<!--                                <input type="text" name="intro"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>获利积分：</label>-->
<!--                                <input type="text" name="profitScore"/>-->
<!--                            </li>-->
                            <li>
                                <label>会员等级id：</label>
                                <input type="text" name="meid"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="used:user:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="used:user:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="used:user:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="used:user:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('used:user:edit')}]];
        var removeFlag = [[${@permission.hasPermi('used:user:remove')}]];
        var sex = [[${@dict.getType('sys_user_sex')}]];
        var types = [[${@dict.getType('used_merchant')}]];
        var prefix = ctx + "used/user";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "用户",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'uid',
                    title: '用户ID',
                    visible: false
                },
                {
                    field: 'username',
                    title: '昵称'
                },
                {
                    field: 'phone',
                    title: '手机号'
                },
                // {
                //     field: 'password',
                //     title: '密码'
                // },
                {
                    field: 'sex',
                    title: '性别',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(sex, value);
                    }
                },
                {
                    field: 'photo',
                    title: '头像',
                    formatter: function(value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'type',
                    title: '用户类型',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(types, value);
                    }
                },
                {
                    field: 'address',
                    title: '地址'
                },
                {
                    field: 'fname',
                    title: '上级用户'
                },
                {
                    field: 'creditScore',
                    title: '信誉积分'
                },
                {
                    field: 'inviteCode',
                    title: '邀请码'
                },
                {
                    field: 'intro',
                    title: '简介'
                },
                {
                    field: 'profitScore',
                    title: '获利积分'
                },
                {
                    field: 'member.memberClass',
                    title: '会员等级id'
                },
                    {
                        field: 'createTime',
                        title: '注册时间'
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.uid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.uid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>